//
//  FTextAreaCell.swift
//  eemall
//
//  Created by zhuxietong on 2018/8/28.
//  Copyright © 2018年 zhuxietong. All rights reserved.
//

import Foundation
import soapp
import Eelay
class VirticalFormCell: FieldCell {
    var field = FieldView()
    
    var field_height:CGFloat = 26
    
    override func didLayoutRules() {
        //        let w = Int(FieldCell.name_width)
        let t = Int(FieldCell.padding_top)
        let b = Int(FieldCell.padding_bottom)
        let l = Int(FieldCell.padding_left)
        let r = Int(FieldCell.padding_right)
        
        contentView.eelay = [
            [titleL,[ee.T.L,[t,l]],"21",100],
            [field,[ee.B.L.R,[-b,l,-r]],"\(field_height)",[titleL,ee.B,ee.T,8]],
            [__line,[ee.L.B.R,[0,0,0]],"\(TP.separatorHeight)"],
        ]
        __line.backgroundColor = ._separator
        self.indicator = .none
        titleL.setContentConstrainToHighLever()
        _ = titleL.ui.font15.text(color: ._foreground)
    }
    
    override func mo_model_reload() {
        titleL.attributedText = mo.model["title",""].ui.font13.color(color: ._foreground).astring + " \(mo.model["mark",""])".ui.font13.cl_888.astring
        field.controller = self.content_controller
        if let f = DataNode<NSMutableDictionary>.path(node: "\(FK.field)", mo.model)
        {
            field.mo.model = f
        }
        else
        {
            if let f = DataNode<NSMutableDictionary>.path(node: "\(FK.fields).0", mo.model)
            {
                field.mo.model = f
            }
        }
    }
    
}
class FTextAreaCell: VirticalFormCell {
    override func addLayoutRules() {
        field = TextAreaField()
        
    }
    override func didLayoutRules() {
        
        let t = Int(FieldCell.padding_top)
        let b = Int(FieldCell.padding_bottom)
        let l = Int(FieldCell.padding_left)
        let r = Int(FieldCell.padding_right)
        
        let l1 = l - 7
        let r1 = r - 7
        contentView.eelay = [
            [titleL,[ee.T.L,[t,l]],"21",100],
            [field,[ee.B.L.R,[-b,l1,-r1]],"60",[titleL,ee.B,ee.T,8]],
            //                [__line,[ee.L.B.R,[0,0,0]],"\(TP.separatorHeight)"],
        ]
        self.indicator = .none
        
        titleL.setContentConstrainToHighLever()
        _ = titleL.ui.font15.text(color: ._foreground)
    }
    
}
